CentOS 7
Sponsored Link

Reset root Password
2016/01/31
 
If you forgot root Password, it's possible to reset it like follows.
[1] Restart System and when GRUB2 boot menu is displayed, Push "e" key.
Next, Proceed like follows to reset root password.
      # push "e" key
      CentOS Linux (3.10.0-327.4.4.el7.x86_64) 7 (Core) with debugging
      CentOS Linux (3.10.0-327.4.4.el7.x86_64) 7 (Core)
      CentOS Linux (3.10.0-327.3.1.el7.x86_64) 7 (Core) with debugging
      CentOS Linux (3.10.0-327.3.1.el7.x86_64) 7 (Core)
      CentOS Linux 7 (Core), with Linux 3.10.0-229.el7.x86_64
      CentOS Linux 7 (Core), with Linux 0-rescue-ffa496be96ad482cb94373394cec7

      Use the ^ and v keys to change the selection.
      Press 'e' to edit the selected item, or 'c' for a command prompt.

setparams 'CentOS Linux (3.10.0-327.4.4.el7.x86_64) 7 (Core)' 'fedora'

        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  c4df086e-3699-4e02-b7cf-b47e614f6920
        else
          search --no-floppy --fs-uuid --set=root c4df086e-3699-4e02-b7cf-b47e614f6920
        fi
        # add "rw init=/bin/bash" to the end of line
        # remove "rhgb", "quiet", "LANG=***" all if there are in this line
        linux16 /vmlinuz-3.10.0-327.4.4.el7.x86_64 root=/dev/mapper/centos-root \
            ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap console=ttyS0,115200n8 
            systemd.debug rw init=/bin/bash
        initrd16 /initramfs-3.10.0-327.4.4.el7.x86_64.img

      Press Ctrl-x to start, Ctrl-c for a command prompt or Escape to
      discard edits and return to the menu. Pressing Tab lists
      possible completions.

      # after inputting above, push "Ctrl-x" key to proceed
.....
.....

[  OK  ] Stopped udev Coldplug all Devices.
         Stopping udev Coldplug all Devices...
[  OK  ] Started Plymouth switch root service.
[    6.814528] systemd-journald[95]: Received SIGTERM from PID 1 (systemd).
bash-4.2# 

# after initramfs switch_root prompt is displayed, do like follows

# set SELinux relabeling on next boot if you enabling SELinux

bash-4.2#
touch /.autorelabel
# set password

bash-4.2#
passwd

Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
# restart System and complete to reset

bash-4.2#
exec /sbin/init
 
Tweet